import 'package:flutter/material.dart';
import 'package:x3_component_core/theme/base_button_theme.dart';

class BaseLightOutlineButton extends StatelessWidget {
  final VoidCallback onPressed;
  final String text;

  /// 是否禁用
  final bool disabled;
  const BaseLightOutlineButton({Key key, @required this.onPressed, this.text, this.disabled = false}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return OutlinedButton(
      style: ButtonStyle(
        shape: MaterialStateProperty.all<OutlinedBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4)))),
        backgroundColor: MaterialStateProperty.all(Colors.white),
        overlayColor: MaterialStateProperty.all(Theme.of(context).primaryColor.withOpacity(0.12)),
        side: MaterialStateProperty.all(BorderSide(color: Color(0xFFF3F3F3), width: 1)),
      ),
      onPressed: disabled == false ? this.onPressed : null,
      child: Text(this.text ?? '', style: getTextStyle(context)),
    );
  }

  TextStyle getTextStyle(BuildContext context) {
    if (disabled == false) {
      return Theme.of(context).textTheme.bodyText2.copyWith(fontSize: BaseButtonTheme.bottomButtonTextSize);
    }
    return Theme.of(context).textTheme.subtitle2.copyWith(fontSize: BaseButtonTheme.bottomButtonTextSize);
  }
}
